<!DOCTYPE html>
<?php
include_once("inc/constants.inc.php");
include_once("inc/connection.php");
session_start();

if(!isset($_SESSION['login']) || empty($_SESSION['login']) || !isset($_SESSION['email']) || empty($_SESSION['email']) || !isset($_SESSION['user_role']))
	{
		header("Location: login.php?error=invalid-access");
		exit(0);
	}
elseif($_SESSION['user_role']==2)
	{
		header("Location: test.php?error=invalid-access");
		exit(0);
	}
if(isset($_GET['isEmpty']) && $_GET['isEmpty']=="yes")
	{
		$empty = true;
	}
if(isset($_GET['isInvalid']) && $_GET['isInvalid']=="yes")
	{
		$emailInvalid = true;
	}
if(isset($_GET['isWrongEmail']) && $_GET['isWrongEmail']=="yes")
	{
		$emailWrong = true;
	}
if(isset($_GET['isNotMatch']) && $_GET['isNotMatch']=="yes")
	{
		$notSame = true;
	}
if(isset($_GET['email']))
	{
		$email = trim(mysql_real_escape_string($_GET['email']));
	}
?>
<html>
	<head>
		<meta charset="utf-8"> 
		<title>Smartek online test | Reset Password</title>
		<link rel="SHORTCUT ICON" href="img/disp/favicon.png" />	
		<link rel="stylesheet" href="css/bootstrap.css"  type="text/css"/>
	</head>
	<body>
		<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
		<script src="js/bootstrap.js"></script>
		
		<div class="container">
			<a href="index.php"><img src="img/disp/logo.png" alt=""></a>
		</div>
		
		<div class="container">
			<div class="row pull-right">
				<div class="span4 pull-right" >
					<div class="pull-right">
						<?php 
						if(!isset($_SESSION['name']) || empty($_SESSION['name'])) echo  "<a href='index.php'>Register</a>";
						if(isset($_SESSION['name']) && !empty($_SESSION['name']) && isset($_SESSION['user_role']) && $_SESSION['user_role']==1) echo  "Welcome ".$_SESSION['name']."! | <a href='dashboard.php'>Dashboard</a> | <a href='logout.php'>Log out</a>"; 
						if(isset($_SESSION['name']) && !empty($_SESSION['name']) && isset($_SESSION['user_role']) && $_SESSION['user_role']==2) echo  "Welcome ".$_SESSION['name']."! | <a href='dashboard.php'>Continue test</a>"; 
						?>
					</div>
				</div>
			</div>
		</div>
		
		
		
		<div class="container">
			<hr class="featurette-divider">
		</div>

		<div class="container">
			<div class="row">
				<div class="span12">
					<form method="post" action="process/reset-user-password.php" id="registrationForm">
						<h4>Please enter the details</h2>
							</br>
							<?php if(isset ($empty) && $empty){echo "<font color='red'>*All fields are mendatory</font><br/>" ;} ?>
							</br>									
								<div class="container">
									<div class="row">
										<div class="span2">Email : </div>
										<div class="span9"><input type="text" tabindex="1" maxlength="60" name="email" 
										value="<?php if(isset($email)){echo $email;}?>"><span class="error" id="email"><?php if(isset($emailInvalid) && $emailInvalid){echo "&nbsp;&nbsp;Please enter a valid email";} if(isset($emailWrong) && $emailWrong) {echo "&nbsp;&nbsp;Email is not registered";}
										?></span></div>								
									</div>
								</div>
								<div class="container">
									<div class="row">
										<div class="span2">New Password :</div>
										<div class="span9"><input type="password" tabindex="2" maxlength="60" name="password" value=""><span class="error" id="password"><?php if(isset($notSame) && $notSame){echo "&nbsp;&nbsp;Password is not matching";} ?></span></div>										
									</div>
								</div>
								<div class="container">
									<div class="row">
										<div class="span2">Confirm Password : </div>
										<div class="span9"><input type="password" tabindex="3" maxlength="20" name="confirmPassword" value=""><span class="error" id="emailPassword"></span></div>										
									</div>
								</div>
								</br>
					   <input name="resetPassword" type="submit" class="btn" value="Reset"/>
					</form>
				</div>
			</div>
		</div>		
		<div class="container marketing">
      <!-- FOOTER -->
		<div class="container">
			<hr class="featurette-divider">
		</div>
      <footer>
        <p>&copy; 2014 SCS &middot; </p>
      </footer>

    </div><!-- /.container -->
	</body>
</html>